package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BuzTaskQuestion;
import com.ruoyi.system.service.IBuzTaskQuestionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动试题Controller
 * 
 * @author ruoyi
 * @date 2023-08-27
 */
@RestController
@RequestMapping("/system/buzTaskQuestion")
public class BuzTaskQuestionController extends BaseController
{
    @Autowired
    private IBuzTaskQuestionService buzTaskQuestionService;

    /**
     * 查询活动试题列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskQuestion:list')")
    @GetMapping("/list")
    public TableDataInfo list(BuzTaskQuestion buzTaskQuestion)
    {
        startPage();
        List<BuzTaskQuestion> list = buzTaskQuestionService.selectBuzTaskQuestionList(buzTaskQuestion);
        return getDataTable(list);
    }

    /**
     * 导出活动试题列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskQuestion:export')")
    @Log(title = "活动试题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BuzTaskQuestion buzTaskQuestion)
    {
        List<BuzTaskQuestion> list = buzTaskQuestionService.selectBuzTaskQuestionList(buzTaskQuestion);
        ExcelUtil<BuzTaskQuestion> util = new ExcelUtil<BuzTaskQuestion>(BuzTaskQuestion.class);
        util.exportExcel(response, list, "活动试题数据");
    }

    /**
     * 获取活动试题详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskQuestion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(buzTaskQuestionService.selectBuzTaskQuestionById(id));
    }

    /**
     * 新增活动试题
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskQuestion:add')")
    @Log(title = "活动试题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BuzTaskQuestion buzTaskQuestion)
    {
        return toAjax(buzTaskQuestionService.insertBuzTaskQuestion(buzTaskQuestion));
    }

    /**
     * 修改活动试题
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskQuestion:edit')")
    @Log(title = "活动试题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BuzTaskQuestion buzTaskQuestion)
    {
        return toAjax(buzTaskQuestionService.updateBuzTaskQuestion(buzTaskQuestion));
    }

    /**
     * 删除活动试题
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskQuestion:remove')")
    @Log(title = "活动试题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(buzTaskQuestionService.deleteBuzTaskQuestionByIds(ids));
    }
}
